def Send():
    HOST = '172.20.10.5'
    PORT = 55555
    BUFSIZ = 4096
    ADDR = (HOST, PORT)
    tcpClientSock = socket(AF_INET, SOCK_STREAM)
    tcpClientSock.connect(ADDR)
    #tcpClientSock.send(bytes('hi', 'utf-8'))
    rec = str(tcpClientSock.recv(BUFSIZ), encoding='utf-8')
    print(rec)
    while True:

        data = input('> ')
        if not data:
            print('重新输入命令：')
            data=input('>')
            while not data:
                print('请重新输入：')
                data = input('>')
            tcpClientSock.send(bytes(data, 'utf-8'))
            data = str(tcpClientSock.recv(BUFSIZ), encoding='utf-8')
            print(data)
                #for i in data:
                #print(i+'\n')
        elif data=='shutdown':
            tcpClientSock.close()
            break
        else:
            tcpClientSock.send(bytes(data, 'utf-8'))
            data = str(tcpClientSock.recv(BUFSIZ), encoding='utf-8')
            if not data:
                print("对方没有发送数据")
            else:
                print(data)

if __name__ == '__main__':
    from socket import *
    Send()
